$(function() {
	//正在使用的位置
	$('#processSeat').click(function() {
		pbUserTypeSeatPage.type = 0;
		selectMenu('processSeat');
	});
	
	//历史位置
	$('#logSeat').click(function() {
		pbUserTypeSeatPage.type = 1;
		selectMenu('logSeat');
	});
	
	$('#processSeat').click();
	
	/**
	 * 选中菜单
	 * @param _id	: 菜单ID
	 */
	function selectMenu(_id) {
		$('#logSeat').attr('class', 'btnorangebig');
		$('#processSeat').attr('class', 'btnorangebig');
		$('#' + _id).attr('class', 'btnorangebig_hover');
		findByUsernamePbUserTypeSeat(1);
	}
});

//获取用户分区位置记录信息
var pbUserTypeSeatPage = new Page("pbUserTypeSeatPage", findByUsernamePbUserTypeSeat, "bodyInfo", "bodyInfoPage");
pbUserTypeSeatPage.size = 5;
pbUserTypeSeatPage.pageSizeArr = [5, 10, 15];
//设置开始字符串
pbUserTypeSeatPage.beginString = '<table><thead><tr>'
							+'<th width="30">编号</th>'
							+'<th width="120">位置名称</th>'
							+'<th>位置描叙</th>'
							+'<th width="120">位置增加的粉丝数</th>'
							+'<th width="120">添加时间</th>'
							+'<th width="100">操作</th></tr></thead><tbody>';
//设置结束字符串
pbUserTypeSeatPage.endString = "</tbody></table>";
//处理Page标签的函数
function findByUsernamePbUserTypeSeat(_page) {
	if(_page != undefined) {
		pbUserTypeSeatPage.page = _page;
	}
	var _data = {
			"page" : pbUserTypeSeatPage.page,
			"size" : pbUserTypeSeatPage.size
		};
	if(pbUserTypeSeatPage.type != undefined) {
		_data["isdel"] = pbUserTypeSeatPage.type;
	}
	
	jQuery.ajax({
		url : webroot + "/pbUserTypeSeat/json/findByUsernamePuts.shtml",
		data : _data,
		type : "POST",
		dataType : "json",
		async : true,
		beforeSend: function(){
			//提交处理的函数
			pbUserTypeSeatPage.pageBeforeSend('<tr><td colspan="6">加载信息中...</td></tr>');
			loading('加载信息中...');
		},
		error : function(json){
			pbUserTypeSeatPage.pageError('<tr><td colspan="6">加载信息出错了~</td></tr>');
			unloading();
		},
		//返回的是一个对象
		success : function(json){
			if(json.result === 'success') {
				//处理数据列表的行信息
				function getResult(obj) {
					var result = '<tr><td>' + obj.id + '</td><td>' + obj.name + '</td><td>'
								+ obj.remark + '</td><td>' + obj.fansnum + '</td><td>' + dateUtil.getFormatDate(new Date(obj.addtime)) + '</td><td>'
								+ '--</td></tr>';
					return result;
				}
				pbUserTypeSeatPage.pageOperate(json.data, { resultFn : getResult, dataNull : '<tr><td colspan="6">没有查找到信息!</td></tr>', pageFootStyle : pbUserTypeSeatPage.pageStyle.defaultStyle });
			}
			else if(json.result === 'error_not_admin') {
				alert('您不是管理员!');
			}
			else if(json.result === 'error_weibo') {
				alert(json.weiboMsg);
			}
			else if(json.result === 'error') {
				alert('请求操作, 系统出现异常!');
			}
			unloading();
		}
	});
}